<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>充值赠品</title>

    <link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/datePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        $().ready(function () {

            var $inputForm = $("#inputForm");
            var $browserButton = $("#browserButton");

        [@flash_message /]

            $browserButton.browser();

            // 表单验证
            $inputForm.validate({
                rules: {
                    startDate: "required"
                    quota: "required",
                    sn: "required"
                }
            });

        });
    </script>
</head>

<body>
<div class="path">
    <a href="${base}/asl-admin/common/index.htm">${message("admin.path.index")}</a> &raquo; 添加充值赠品
</div>
<form id="inputForm" action="save.htm" method="post">
    <table class="input">
        <tr>
            <th> 赠品活动开始日期: </th>
            <td colspan="2">
                <input type="text" id="startDate" name="startDate" class="text Wdate"
                       onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', maxDate: '#F{$dp.$D(\'endDate\')}'});"/>&nbsp;&nbsp;
                该项为空时表示保存之后立即有效
            </td>
        </tr>
        <tr>
            <th> 赠品活动结束日期: </th>
            <td colspan="2">
                <input type="text" id="endDate" name="endDate" class="text Wdate"
                       onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', minDate: '#F{$dp.$D(\'startDate\')}'});"/>&nbsp;&nbsp;
                该项为空时表示保存之后可永久领取
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>最低充值额度:
            </th>
            <td>
                <input type="text" name="quota" class="text" maxlength="200" id="quota"/>&nbsp;&nbsp;  单位: 元
            </td>
        </tr>
        <tr>
            <th> <span class="requiredField">*</span> 赠品项 </th>
            <td>
                <input type="text" name="sn" id="sn" class="text" maxlength="200"/>&nbsp;&nbsp; <span id="proTxt">填入商品编号查找商品</span>
            </td>
        </tr>
        <tr>
            <th> 赠品项标题 </th>
            <td>
                <input type="text" name="title" class="text" maxlength="200"/>&nbsp;&nbsp; 该项为空时默认生成标题 “充值满 <span id="quotaText">__</span> 元赠品”
            </td>
        </tr>

        <tr>
            <th>
                &nbsp;
            </th>
            <td>
                <input type="submit" class="button" value="${message("admin.common.submit")}"/>
                <input type="button" class="button" value="${message("admin.common.back")}"
                       onclick="location.href='list.htm'"/>
            </td>
        </tr>
    </table>
</form>
<script type="text/javascript">
    $("#quota").on("blur", function () {
        if ($(this).val()){
            $("#quotaText").html($(this).val());
        }
    });
    $("#sn").on("blur", function () {
        var sn=$(this).val();
        if ($(this).val()){
            $.get("/asl-admin/giveaway/product.htm",{sn:sn}).done(function(data){
                if (data.code==0){
                    $("#proTxt").html(data.data);
                }else{
                    $("#proTxt").html("该商品不存在！");
                }
            });
        }
    });

</script>
</body>

</html>